package com.nulldev.util.java.swing.extSwing.iNotify;

import java.awt.Color;
import java.awt.Rectangle;

import org.w3c.dom.css.Rect;

public class Message {
	private final String title, message;
	private final MessageType type;
	
	public Message(final String title, final String message, final MessageType type) {
		this.title = title;
		this.message = message;
		this.type = type;
	}
	
	private long endAfter = -1L;
	
	public void endAfter(final long end) {
		this.endAfter = end;
	}
	
	public long endsAfter() {
		return this.endAfter;
	}
	
	public boolean autoEnds() {
		return this.endAfter > 0L;
	}
	
	private boolean _init_end_waiting;
	public void init_end_wait() {
		if (!_init_end_waiting) {
			_init_end_waiting = true;
		}
	}
	
	public boolean _init_end_isWaiting() {
		return this._init_end_waiting;
	}
	
	public String getTitle() {
		return this.title;
	}
	
	public String getMessage() {
		return this.message;
	}
	
	public MessageType getType() {
		return this.type;
	}
	
	@Override
	public boolean equals(final Object o) {
		if (o instanceof Message) {
			final Message comp = (Message) o;
			return comp.getTitle().equals(this.getTitle()) &&
					comp.getMessage().equals(this.getMessage()) && comp.getType().equals(this.getType());
		}
		return (this == o);
	}
	
	public static enum MessageType {
		
		SUCCESS(Color.GREEN),
		WARNING(Color.ORANGE),
		ERROR(Color.RED),
		;
		
		private final Color color;
		private MessageType(final Color color) {
			this.color = color;
		}
		
		public Color getColor() {
			return this.color;
		}
	}
}
